import AirPlane from "./AirPlane.js";
import Pool from "./Pool.js";
import SilverBullet from "./SilverBullet.js";
import Vector2 from "./Vector2.js";

export default class Player extends AirPlane {
  weapenPoints:Array<Vector2> = new Array<Vector2>()
  constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0, imgPath: string = '') {
    super(x, y, width, height, imgPath)
    this.attackSpeed = 150
    this.weapenPoints[0] = new Vector2(28,8)
    this.weapenPoints[1] = new Vector2(84,8)
  }
  shootReay:boolean = true
  shoot(){
    let bults = new Array<SilverBullet>()
    if(this.shootReay){
      this.shootReay = false
      setTimeout(() => {
        this.shootReay = true
      }, this.attackSpeed);
      this.weapenPoints.forEach(e=>{
        let x = this.x + e.x - 5
        let y = this.y + e.y - 28
        // let b = new SilverBullet(x,y)
        let b = Pool.generateBullet()
        b.x = x
        b.y = y
        bults.push(b)
      })
    }
    return bults
  }
}